﻿ManagePanel = function() {
		ManagePanel.superclass.constructor.call(this, {
					id : 'manage-panel',
					region : 'west',
					baseCls : 'manage-panel',
					loader : new Ext.tree.TreeLoader({
								dataUrl : "getFunctionTreeAction.action",
								preloadChildren : true
							}),
					root : new Ext.tree.AsyncTreeNode({
								expanded : true
							}),
					width : 180,
					minWidth : 150,
					split : true,
					collapsible : true,
					collapseMode : 'mini',
					animCollapse : false,
					cmargins : '0 5 5 5',
					autoScroll : true,
					rootVisible : false,
					border : false,
					bodyStyle : 'background:transparent;',
					lines : false
				});
		this.getSelectionModel().on('beforeselect',function(sm,node){
			return node.isLeaf();
		});
	}
	Ext.extend(ManagePanel, Ext.tree.TreePanel, {
				selectModule : function(id) {
				}
			});
			
Ext.onReady(function(){
	Ext.BLANK_IMAGE_URL = 'images/s.gif';
	Ext.QuickTips.init();
	
	// 各功能模块的管理面板，是一个树型面板
	var managePanel=new ManagePanel();
	managePanel.on('click',function(node,e){
		if(node.isLeaf()){
			e.stopEvent();
			var id = 'panels-' + node.attributes.id;
			var panel=mainPanel.getComponent(id);
			if(panel){
				mainPanel.layout.setActiveItem(panel);
				panel.fireEvent('activate');
			}else{
				var autoLoad = {url: node.attributes.href,scripts:true};
				panel=mainPanel.add(new Ext.Panel({
					id:id,
					autoScroll:true,
					autoLoad: autoLoad
//					html : '<iframe name="personmessage" scrolling="auto" ' +
//							'frameborder="0" width="100%" height="100%" src="test.html"></iframe>'
				}));
				mainPanel.layout.setActiveItem(panel);
			}
		}
	});
	//显示欢迎信息的面板
	var startPanel = new Ext.Panel({
		id : 'start',
		autoWidth:true,
		autoScroll : true,
		margins : '10 5 5 0',
		cls : 'start',
		html : "<br/><br/>您好，欢迎使用科研管理系统！<br/><br/><br/><img src='images/green home.jpg'></img>"
	});
	/*
	//人员信息面板
	var personMessagePanel = new Ext.Panel({
		id:'panels-PersonMessage',
		autoWidth:true,
		autoScroll : true,
		margins : '10 5 5 0',
//		html : '<iframe name="personmessage" scrolling="auto" frameborder="0" width="100%" height="100%" src="test.html"></iframe>' 
		autoLoad:{url:'personmessage.html',scripts:true}
	});*/
    var mainPanel=new Ext.Panel({
    	id:'main-panel',
        region:'center',
        layout:'card',
        baseCls:'main-panel',
        activeItem:0,
        items:[startPanel]
    });
    //整个视图
	var viewport = new Ext.Viewport({
        layout:'border',
        items: [
            {
                region:'north',
                html:'<br/><a href="logoutAction.action" style:"underline:true;">退出</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
                baseCls:'logo',
				height:80
            },{
                region:'south',
                html:'<center>&copy;&nbsp;&nbsp;河北农大信息学院 2009</center>',
                baseCls:'footer-panel'
            }, mainPanel, managePanel
        ]
    });
	
});